/**
 * Add full editor
 */
function fullEditor(id){
    CKEDITOR.replace(id,
    {
        toolbar:
        [
            ['Source','-','Save','NewPage','Preview','-','Templates'],
            ['Cut','Copy','Paste','PasteText','PasteFromWord','-','Print', 'SpellChecker', 'Scayt'],
            ['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
            ['Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField'],
            '/',
            ['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],
            ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
            ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
            ['Link','Unlink','Anchor'],
            ['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak'],
            '/',
            ['Styles','Format','Font','FontSize'],
            ['TextColor','BGColor'],
            ['Maximize', 'ShowBlocks','-','About']
        ],
        language:'vi',
        height:500,
        tabIndex:4
    });
}

/**
 * Add full editor - back end
 */
function addCkEditorAdmin(id){
    CKEDITOR.replace(id,
    {
        toolbar:
        [
            ['Source','-','NewPage','-','Templates'],
            ['Cut','Copy','Paste','PasteText','PasteFromWord','-','SpellChecker','Scayt'],
            ['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
            ['Checkbox','Radio','TextField','Textarea','Select','ImageButton'],
            '/',
            ['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],
            ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
            ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
            ['Link','Unlink','Anchor'],
            ['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak'],
            '/',
            ['Styles','Format','Font','FontSize'],
            ['TextColor','BGColor'],
            ['Maximize','ShowBlocks','-','About']
        ],
        language:'vi',
        height:500,
        tabIndex:4
    });
}

/**
 * Add full editor - back end
 */
function addCkEditorAdminSubPage(id, height){
    CKEDITOR.replace(id,
    {
        toolbar:
        [
            ['Source','-','Templates'],
            ['Cut','Copy','Paste','PasteText','PasteFromWord','-','SpellChecker','Scayt'],
            ['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
            ['TextField','Textarea','Select','ImageButton'],
            '/',
            ['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],
            ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
            ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
            
            ['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak'],
            '/',
            ['Styles','Format','Font','FontSize'],
            ['TextColor','BGColor'],
            ['Maximize','ShowBlocks'], ['Link','Unlink','Anchor']
        ],
        language:'vi',
        height:height,
        tabIndex:4,
        contentsCss:contentCssSubpage
    });
}

/**
 * Add editor for post article - front end
 */
function addCkEditor(id){
    CKEDITOR.replace( id,
    {
        toolbar:
        [
            ['Source','-','NewPage','-','Templates'],
            ['Cut','Copy','Paste','PasteText','PasteFromWord','-','SpellChecker','Scayt'],
            ['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
            ['Checkbox','Radio','TextField','Textarea','Select','ImageButton'],
            '/',
            ['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],
            ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
            ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
            ['Link','Unlink','Anchor'],
            ['Image','Table','HorizontalRule','Smiley','SpecialChar','PageBreak'],
            '/',
            ['Styles','Format','Font','FontSize'],
            ['TextColor','BGColor'],
            ['Maximize','ShowBlocks','-','About']
        ],
        resize_dir:'vertical',
        language:'vi',
        tabIndex:3,
        height:500,
        filebrowserBrowseUrl:'',
        filebrowserImageBrowseUrl:'',
        filebrowserFlashBrowseUrl:'',
        filebrowserUploadUrl:'',
        filebrowserImageUploadUrl:'/kcfinder/upload.php?type=images',
        filebrowserFlashUploadUrl:''
    });
}

function inserHtml(img,width){
    if(typeof width == 'undefined'){
        width = 500;
    }

    img = "<img src='"+img+"' width='"+width+"'/>";
    CKEDITOR.instances['ck_content'].insertHtml(img);
    goToByScroll('article');
}

function setCusorEditor(){
    CKEDITOR.instances['ck_content'].insertHtml('');
}